package com.seven.good.controller;


import com.seven.good.client.PayClient;
import com.seven.good.client.PersonClient;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class TestController {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    PersonClient personClient;

    @Autowired
    PayClient payClient;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/createorder")
    @ResponseBody
   public String test2(HttpServletRequest request){
        payClient.createOrder(1,1,"200",1);
        return "create OK";
    }

    @RequestMapping("/tw")
    @ResponseBody
    public String test3(){
        return payClient.test();
    }

    @RequestMapping("/aaa")
    @ResponseBody
    public String test() {
        //Map data = payClient.test();
        return personClient.test();

    }

    @RequestMapping("/send")
    @ResponseBody
    public String Btest(Integer gid,Integer uid,String price) {
        System.out.println("---"+gid);
        System.out.println("---"+uid);
        System.out.println("---"+price);
        Map map = new HashMap();
       /* map.put("msg","成功");
        map.put("type",1);
        rabbitTemplate.convertAndSend("springboot-exchange", "msg", map);
        System.out.println("SEND MESSAGE SUCCESSFUL");*/

        // 生成订单，订单号，
        payClient.createOrder(gid,uid,price,1);
        // 退款，保证金

        payClient.getRefundOrders(gid,2,uid);




        System.out.println("生成订单");

        return "OK";

    }

}
